//
//  LaunchViewController.swift
//  test-ios
//
//  Created by wyz5204 on 2023/2/24.
//

import UIKit

class LaunchViewController: UITabBarController {

    public var imageArr = [UIView]()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        /// 文字色
        tabBar.tintColor = UIColor.gl_theme
        
        /// 设置背景色
        tabBar.barTintColor = .white
        
        /// 取消不透明效果   默认 true
        tabBar.isTranslucent = false
        
        tabBar.layer.shadowColor = UIColor.gl_shadow.cgColor
        tabBar.layer.shadowOpacity = 0.4
        tabBar.layer.shadowOffset = CGSize.init(width: 0, height: -1)
        tabBar.shadowImage = UIImage()
        tabBar.backgroundImage = UIImage()
        
        
        addSubVC()
        
        gl_after_async(0.3) {
            self.didSelect(0)
        }
        
    }
    
    
    public func didSelect(_ index: Int) {
        if let item = self.tabBar.items?[index] {
            self.tabBar(self.tabBar, didSelect: item)
        }
    }
    
    private func addSubVC() {
        
        let shopVC = ListViewController()
        addChildVC(viewController: shopVC, barTitle: "首页", imageName: "tabbar_shop")
        
        let catVC = ListViewController()
        addChildVC(viewController: catVC, barTitle: "分类", imageName: "tabbar_category")
        
        let cartVC = ImageListViewController()
        addChildVC(viewController: cartVC, barTitle: "购物车", imageName: "tabbar_cart")
        
        let mineVC = ViewController()
        addChildVC(viewController: mineVC, barTitle: "我的", imageName: "tabbar_mine")
        
    }
    
    private func addChildVC(viewController: UIViewController, barTitle: String, imageName: String) {
        
        let naviVC = LaunchNavViewController.init(rootViewController: viewController)
        
        addChild(naviVC)
    }

}
